#ifndef _SOURCE_SIMPLELABELWRITER_H_
#define _SOURCE_SIMPLELABELWRITER_H_

//---------------------------------------------------------------------------
/// CSimpleLabelWriter : simple tool class to write XML element to file.
//---------------------------------------------------------------------------

const int g_maxContextLength = 512;

struct FILE;

class CSimpleLabelWriter
{
public:
	CSimpleLabelWriter(void);
	~CSimpleLabelWriter(void);

	bool OpenFile(const char* name);
	// write text between one label and its end label.
	bool WriteText(const char* text);
	// write label and its attributes. one label could have 10 attributes at most.
	// isDone : true if the label likes "<.../>" or false if the lable likes "<...>"
	bool WriteLabel(const char* name, const bool isDone, const char* attr1 = 0, const char* value1 = 0,
		const char* attr2 = 0, const char* value2 = 0,const char* attr3 = 0, const char* value3 = 0,
		const char* attr4 = 0, const char* value4 = 0,const char* attr5 = 0, const char* value5 = 0,
		const char* attr6 = 0, const char* value6 = 0,const char* attr7 = 0, const char* value7 = 0,
		const char* attr8 = 0, const char* value8 = 0,const char* attr9 = 0, const char* value9 = 0,
		const char* attr10 = 0, const char* value10 = 0);
	// write end label for unfinished label.
	bool WriteEndLable(void);

protected:
	char m_szCurrentName[g_maxContextLength];
	int m_iScope;
	int m_bIsNeedWriteEndLable;
	FILE* m_pFilePtr;
};

#endif // #ifndef _SOURCE_SIMPLELABELWRITER_H_